//package com.arcvideo.acsconnect.ui.presenter;
//
//import com.arcvideo.acsconnect.app.GlobalConstant;
//import com.arcvideo.acsconnect.app.UserDataCenter;
//import com.arcvideo.acsconnect.rest.model.WXAccessToken;
//import com.arcvideo.acsconnect.rest.model.WXUserInfo;
//import com.arcvideo.acsconnect.rest.service.AppService;
//import com.arcvideo.acsconnect.ui.view.LoginView;
//import com.framework.core.bean.RestError;
//import com.framework.core.mvp.BasePresenter;
//import com.framework.core.mvp.IObserver;
//
//import rx.Observable;
//import rx.Observer;
//import rx.android.schedulers.AndroidSchedulers;
//import rx.functions.Func1;
//import rx.schedulers.Schedulers;
//
//public class LoginPresenter extends BasePresenter<LoginView> {
//
//    AppService mAppService;
//
//    public LoginPresenter() {
//        super();
//        mAppService = mRetrofit.create(AppService.class);
//    }
//
//    public void getUserInfo(String code) {
//        mAppService.getAccessToken(GlobalConstant.APP_ID_WEIXIN,
//                GlobalConstant.APP_SECRET_WEIXIN, code, "authorization_code")
//                .flatMap(new Func1<WXAccessToken, Observable<WXUserInfo>>() {
//                    @Override
//                    public Observable<WXUserInfo> call(WXAccessToken wxAccessToken) {
//                        UserDataCenter.getInstance().setWXAccessToken(wxAccessToken);
//                        return mAppService.getUserInfo(wxAccessToken.getAccess_token(),
//                                wxAccessToken.getOpenid(), "zh_CN");
//                    }
//                })
//                .subscribeOn(Schedulers.io())
//                .observeOn(AndroidSchedulers.mainThread())
//                .subscribe(new IObserver<WXUserInfo>(this, true) {
//                    @Override
//                    public boolean onFailed(RestError restError) {
//                        return false;
//                    }
//
//                    @Override
//                    public void onNext(WXUserInfo wxUserInfo) {
//                        UserDataCenter.getInstance().setUserInfoBean(wxUserInfo);
//                        UserDataCenter.sIsWxLogin = true;
//                        getMvpView().getUserInfoSuccess(wxUserInfo);
//                    }
//                });
//    }
//}